<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<link href="/css/index.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="/js/Calendar.js"></script>
<script type="text/javascript">
    $(function(){
        //全选
        $("#all").click(function(){
            var flag = $(this).attr("checked");
            $("[name=resUuids]").attr("checked",flag == "checked");
        });
        //反选
        $("#reverse").click(function(){
            $("[name=resUuids]").each(function(){
                //使用each操作实现对每个组件的操作
                var flag = $(this).attr("checked");
                $(this).attr("checked", !(flag =="checked"));
            });
            checkSelect();
        });

        //绑定组件
        $("[name=resUuids]").click(function(){
            //将全选的状态设置为基于所有组件的综合状态值
            checkSelect();
        });

        function checkSelect(){
            var allFlag = true;
            $("[name=resUuids]").each(function(){
                var flag = $(this).attr("checked") == "checked";
                //&:位运算与	 &&:逻辑与
                allFlag = allFlag && flag;
            });
            $("#all").attr("checked",allFlag);
        }

    });
</script>
<div class="content-right">
    <div class="content-r-pic_w">
        <div style="margin:8px auto auto 12px;margin-top:6px">
            <span class="page_title">角色管理</span>
        </div>
    </div>
    <div class="content-text">
        <div class="square-order">
            <s:form action="role_save" method="post">
                <div style="border:1px solid #cecece;">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr bgcolor="#FFFFFF">
                            <td>&nbsp;</td>
                        </tr>
                    </table>
                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr bgcolor="#FFFFFF">
                            <td width="18%" height="30" align="center">角色名称</td>
                            <td width="32%">

                                <s:textfield size="25" name="rm.name"></s:textfield>
                            </td>
                            <td width="18%" align="center">角色编码</td>
                            <td width="32%">

                                <s:textfield size="25" name="rm.code"></s:textfield>
                            </td>
                        </tr>
                        <tr bgcolor="#FFFFFF">
                            <td colspan="4">&nbsp;</td>
                        </tr>
                        <tr bgcolor="#FFFFFF">
                            <td width="18%" height="30" align="center">资源名称</td>
                            <td width="82%" colspan="3">
                                <input type="checkbox" id="all">全选&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="checkbox" id="reverse">反选
                            </td>
                        </tr>
                        <tr bgcolor="#FFFFFF">
                            <td width="18%" height="30" align="center">&nbsp;</td>
                            <td width="82%" colspan="3">
                                <s:checkboxlist list="resList" name="resUuids" listKey="uuid" listValue="name"/>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="order-botton">
                    <div style="margin:1px auto auto 1px;">
                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td>
                                    <a href="javascript:document.forms[0].submit()"><img src="/images/order_tuo.gif"
                                                                                         border="0"/></a>
                                </td>
                                <td>&nbsp;</td>
                                <td><a href="#"><img src="/images/order_tuo.gif" border="0"/></a></td>
                                <td>&nbsp;</td>
                                <td><a href="#"><img src="/images/order_tuo.gif" border="0"/></a></td>
                            </tr>
                        </table>
                    </div>
                </div>
            </s:form>
        </div><!--"square-order"end-->
    </div><!--"content-text"end-->
    <div class="content-bbg"><img src="/images/content_bbg.jpg"/></div>
</div>
